package com.mad.base.objects.ships;

import com.mad.base.objects.GameObject;
import com.mad.base.system.EDirection;
import com.mad.base.system.ID;
import com.mad.base.system.Range;

public class Ship extends GameObject {

    private final EShipType shipType ; 
    private Range<ID> coveredFields ;  
    
    public EShipType getShipType()
    {
        return shipType;
    }

    @SuppressWarnings( "unchecked" )
    public Ship(EShipType type, ID bowID, EDirection dir)
    {
        this.shipType = type ; 
        this.coveredFields = new Range<ID>(bowID, ID.calculateID( bowID, type.getLength(), dir )); 
    }

    public boolean isHit(ID possibleHit){
        return this.coveredFields.isInRange( possibleHit ); 
    }
    
    @Override
    public String toString(){
        return "ship: "+this.shipType.toString()+", "+this.coveredFields.toString(); 
    }
    
}
